//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - SaaS Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shp.Runtime.Sitka.ServiceGateway.SitkaClient;
using System.Globalization;
using System.Web.Services.Protocols;

namespace Shp.Runtime.Sitka.ServiceGateway.Tests
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class ServiceGatewayFixture
    {
        public ServiceGatewayFixture()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion        

        [TestMethod]
        [Ignore]
        public void ShouldCreateAuthority()
        {
            using (SitkaSoapServiceClient client = new SitkaSoapServiceClient())
            {
                client.ClientCredentials.UserName.UserName = "litodamiani";
                client.ClientCredentials.UserName.Password = "hb6i#vekx!1367o$rsb3";

                Scope authorityScope = new Scope();
                authorityScope.AuthorityId = String.Format(CultureInfo.InvariantCulture, "litware{0}", Guid.NewGuid()).Replace("-", "x").ToLower();                
                
                Scope serviceScope = new Scope();
                Authority authority = new Authority();
                authority.Id = authorityScope.AuthorityId;

                client.Create(serviceScope, authority);

                Entity authorityRetrieved = client.Get(authorityScope);

                Assert.IsNotNull(authorityRetrieved);
            }
        }
    }
}
